﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RssMenuAddLink.ascx.cs" Inherits="admin_webparts_Plug_ins_RssNews_RssMenuAddLink" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="NTTHAO.Web.BL.Rss" %>

<script type="text/javascript">
function confirmDelete() {
    var msg = '<%=LanguageUtility.GetLanguageText("CONFIRM_DELETE", Session).Replace("<br />", "\\n")%>';
    return confirm(msg);
}
function showHideDetail(that) {
    var oSite = that.parentNode;
    var oDetail = document.getElementById(oSite.id + '_links');
    if(oDetail) {
        var clsName = that.className;
        if (clsName.toLowerCase().indexOf('exp') >= 0) {
            that.className = 'coll';
            oDetail.style.display = '';
        } else {
            that.className = 'exp';
            oDetail.style.display = 'none';
        }
    }
}
var sites = new Array();
function doSubmit() {
    for(var i = 0; i < sites.length; i++) {
        var oLinks = document.getElementById(sites[i] + '_links');
        if (oLinks) {
            oLinks.style.display = '';
        }
    }
    return true;
}
</script>
<form id="frmInput" runat="server" onsubmit="return doSubmit();">
<%
    string bUrl = "?type=" + Request.QueryString["type"] + "&name=" + Request.QueryString["name"] + "&item=" + Request.QueryString["item"] + "&g=" + Request.QueryString["g"] + "&m=" + Request.QueryString["m"];
    bool isAdmin = Context.User.Identity.Name.Equals("admin", StringComparison.OrdinalIgnoreCase);
    int langID = LanguageUtility.GetLanguageID();
    int siteID = WebGlobal.GetSite().ID;
%>
<div class="tip" style="position: relative;">
	<h1 style="left: 0px; position: relative;">Thay đổi liên kết RSS của menu</h1>
	<div style="display: block; width: 32px; height: 32px; float: right; position: absolute; top: 5px; right: 5px;"><a title="Click vào đây để quay lại." href="<%=bUrl %>&action=detail"><img alt="Back" src="resources/images/Back.png" /></a></div>
</div>
<div class="path border" style="margin-bottom: 10px; overflow: hidden;">
    <span class="name" style="float: left;"><%=_Group.Name %></span><div style="float: left; display: inline;"><%
    RssMenu menu = _Menu;
    while (menu != null)
    {
%><span class="name" style="float: right;"><span class="sepa">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><%=menu.Text%></span><%
        menu = RssMenu.GetRssMenu(menu.ParentID);
    } 
%></div>
</div>
<div style="text-align: left; margin-bottom: 10px;">
    <span id="spSave" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" /></span></span>
    <span id="spCancel1" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="<%=bUrl %>&action=detail"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
    <script type="text/javascript">
        YAHOO.util.Event.onContentReady("spSave", function () {
            var spSave = new YAHOO.widget.Button("spSave");
        });
        YAHOO.util.Event.onContentReady("spCancel1", function () {
            var spCancel1 = new YAHOO.widget.Button("spCancel1");
        });
    </script>
</div>
<div class="stairs oh" style="border: solid 1px #89D;"><%
    try
    {
        if (RssSite.RssSites != null)
        {
            foreach (RssSite site in RssSite.RssSites)
            {
                if (!site.Activated) { continue; }
%><script type="text/javascript">sites[sites.length] = 'site_<%=site.ID %>';</script>
    <div id="site_<%=site.ID %>" class="step b" style="border-left: none; border-bottom: dashed 1px #89D;">
        <p class="exp" onclick="showHideDetail(this);">
            <span class="icon-back" style="background-image:url(<%=site.ShortcutIcon %>)"><%=site.SiteName %></span>
        </p>
    </div>
    <div id="site_<%=site.ID %>_links" class="stair" style="display: none;"><%
                DataTable tb = RssMenuLink.GetAllLinksWithRelatedMenu(site.ID, _Menu.ID, langID, 1);
                if (tb != null)
                {
                    for (int i = 0; i < tb.Rows.Count; i++)
                    {
                        DataRow row = tb.Rows[i];
                        string id = row[RssLink.ID__COLUMN_NAME].ToString();
                        string name = row[RssLink.NAME__COLUMN_NAME].ToString();
                        string url = row[RssLink.RSSURL__COLUMN_NAME].ToString();
                        int defaultFrequency = Convert.ToInt32(row[RssLink.FREQUENCY__COLUMN_NAME]);
                        int frequency = Convert.ToInt32(row["DetailFrequency"]);
                        bool activated = Convert.ToBoolean(row["DetailActivated"]);
%>
        <div class="step">
            <p><input type="checkbox" id="link_<%=id %>" name="links" value="<%=id %>"<%=frequency >= 0 ? " checked=\"checked\"" : "" %> /><label for="link_<%=id %>"><%=name%></label></p>
        </div><%
                    }
                }
%>
    </div><%
            }
        }
    }
    catch (Exception ex)
    {
        HtmlGenericControl ctrl = new HtmlGenericControl("div");
        ctrl.InnerHtml = "<p>" + ex.Message + "</p><p>" + ex.StackTrace + "</p>";
        this.Controls.Add(ctrl);
    }
%>
</div>
<div style="text-align: left; margin-top: 10px;">
    <span id="spSave2" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><asp:Button ID="btnSave2" runat="server" OnClick="btnSave_Click" Text="Save" /></span></span>
    <span id="spCancel2" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="<%=bUrl %>&action=detail"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
<script type="text/javascript">
    YAHOO.util.Event.onContentReady("spSave2", function () {
        var spSave2 = new YAHOO.widget.Button("spSave2");
    });
    YAHOO.util.Event.onContentReady("spCancel2", function () {
        var spCancel2 = new YAHOO.widget.Button("spCancel2");
    });
</script>
</div>
</form>